//
//  CNMineHeadView.m
//  BeeQuick_19
//
//  Created by clinging on 16/9/24.
//  Copyright © 2016年 CN Team. All rights reserved.
//

#import "CNMineHeadView.h"

@implementation CNMineHeadView
-(instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        
        //设置头部视图的图片
        self.image = [UIImage imageNamed:@"v2_my_avatar_bg"];
        //创建一个设置的button
        UIButton * button = [[UIButton alloc]init];
        //设置button的图片
        [button setImage:[UIImage imageNamed:@"v2_my_settings_icon"] forState:UIControlStateNormal];
        //添加
        [self addSubview:button];
        
        //创建头像
        UIImageView *headImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"v2_my_avatar"]];
        //添加
        [self addSubview:headImageView];
        
        
        //创建一个电话号码的label
        UILabel * phoneLabel = [[UILabel alloc]init];
        phoneLabel.text = @"12345678901";
        //设置label的字体大小
        phoneLabel.font = [UIFont systemFontOfSize:18];
        //设置label的颜色
        phoneLabel.textColor = [UIColor whiteColor];
        //设置居中
        phoneLabel.textAlignment = NSTextAlignmentCenter;
        //添加
        [self addSubview:phoneLabel];
        
        //设置label设置的约束
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self).offset(-10);
            make.top.equalTo(self).offset(20);
            make.width.height.mas_equalTo(50);
            
        }];
        //设置头像的约束
        [headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(80);
        }];
        // 设置号码的约束
        [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(headImageView.mas_bottom).offset(10);
            make.leading.trailing.equalTo(self);
            make.height.equalTo(@30);
        }];
    }
    return self;
}
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//    if (section == 0) {
//        return 0.01;//这里是设置tableView的第一部分的头视图高度为0.01
//    }else {
//        return 10;//这里设置其他部分的头视图高度为10
//    }
//}

@end
